clear
version 7.0
#delimit ;
cd "Z:\interactionmodels\";                       * SET WORKING DIRECTORY;
log using getdata\getdata1xls_mozaffar.log, replace;

*     ***************************************************************** *;
*     ***************************************************************** *;
*       File-Name:      getdata1xls_mozaffar.do                         *;
*       Date:           01/09/2007                                      *;
*       Author:         MRG                                             *;
*       Purpose:        Recode Mozaffar et al. (2003) EXCEL and relabel.*;
*       Input File:     mozaffar_xls.dta, golder1.dta                   *;
*       Output File:    getdata1xls_mozaffar.log                        *;
*       Data Output:    XLS_mozaffar.dta                                *;
*       Previous file:                                                  *;
*       Machine:                                                        *;
*     ****************************************************************  *;
*     ****************************************************************  *;

set mem 10m;

use getdata\mozaffar_xls.dta;

*     ****************************************************************  *;
*           Summary Statistics                                          *;
*     ****************************************************************  *;

sum;

*     ****************************************************************  *;
*               Recode and relabel variables to sensible names          *;
*     ****************************************************************  *;

rename countrys country_xls;
label var country_xls "country";

rename enlp legparties_xls;
label var legparties_xls "effective number of parliamentary parties";

rename enep elecparties_xls;
label var elecparties_xls "effective number of electoral parties";

rename dismagni avemagnitude_xls;
label var avemagnitude_xls "average district magnitude";

rename logmagni logmag10_xls;
label var logmag10_xls "log of average district magnitude (base 10) - NOT natural log";

rename proxmity proximity_xls;
label var proximity_xls "temporal proximity of legislative and presidential elections";

rename enpres prescandidate_xls;
label var prescandidate_xls "effective number of presidential candidates";

rename proxenpr prox_prescandidate_xls;
label var prox_prescandidate_xls "proximity * prescandidate";

rename ltfragto fragmentation_xls;
label var fragmentation_xls "fragmentation index (mozaffar 2003)";

rename fragtosq fragmentation2_xls;
label var fragmentation2_xls "fragmentation squared";

rename contot concentration_xls;
label var concentration_xls "concentration of ethnic groups";

rename intertot frag_conc_xls;
label var frag_conc_xls "fragmentation * concentration";

rename intertsq frag2_conc_xls;
label var frag2_conc_xls "fragmentation2 * concentration";

rename lmgtrpls logmag10_frag2_conc_xls;
label var logmag10_frag2_conc_xls "logmag10 * fragmentation2 * concentration";

rename elf elf_xls;
label var elf_xls "ethno-linguistic group index";

rename elflmag logmag10_elf_xls;
label var logmag10_elf_xls "logmag10* elf";

rename pregblmg pregb_logmag10_xls;
label var pregb_logmag10_xls "pregb * logmag10";

rename pregb pregb_xls;
label var pregb_xls "politically relevant ethnic group B count";

*     ****************************************************************  *;
*           Create new variables that we might want.                    *;
*     ****************************************************************  *;

gen logmag_xls = ln(avemagnitude);
label var logmag_xls "natural log of average district magnitude";

*     ****************************************************************  *;
*       Create necessary interaction terms involving logmag10           *;
*     ****************************************************************  *;

gen logmag10_conc_xls = logmag10_xls*concentration_xls;
label var logmag10_conc_xls "logmag10_xls*concentration_xls";

gen logmag10_frag_xls = logmag10_xls*fragmentation_xls;
label var logmag10_frag_xls "logmag10_xls*fragmentation_xls";

gen logmag10_frag_conc_xls = logmag10_xls*fragmentation_xls*concentration_xls;
label var logmag10_frag_conc_xls "logmag10_xls * fragmentation_xls * concentration_xls";

*     ****************************************************************  *;
*       Now create necessary interaction terms involving logmag         *;
*     ****************************************************************  *;

gen logmag_conc_xls = logmag_xls*concentration_xls;
label var logmag_conc_xls "logmag_xls*concentration_xls";

gen logmag_frag_xls = logmag_xls*fragmentation_xls;
label var logmag_frag_xls "logmag_xls*fragmentation_xls";

gen logmag_frag_conc_xls = logmag_xls*fragmentation_xls*concentration_xls;
label var logmag_frag_conc_xls "logmag_xls * fragmentation_xls * concentration_xls";

sum;

describe;

*     ****************************************************************  *;
*       Now merge this dataset with goldershort.dta so that we have     *;
*       variables indicating the year of the election and whether it    *;
*       was a dictatorship.                                             *;
*     ****************************************************************  *;

merge using getdata\golder1.dta, keep(year_nyu dictator_nyu) nokeep;
drop _merge;

*     ****************************************************************  *;
*                           Reorder the data                            *;
*     ****************************************************************  *;

order country year_nyu dictator_nyu;

*     ****************************************************************  *;
*                                   Save                                *;
*     ****************************************************************  *;

save getdata\XLS_mozaffar, replace; 
log close;
exit;
